<template>
  <div class="bg-white mt-[10px]">
    <BaseHead style="border-bottom: 0">基本信息</BaseHead>
    <BaseTable>
      <tr>
        <td class="td-name">申请计划名称</td>
        <td>{{ detailData.name }}</td>
        <td class="td-name">项目分类</td>
        <td>
          <CommonTreeLabel
            :dataList="projectTypeList"
            :value="detailData.projectTypeId"
            labelKey="labelLocal"
          />
        </td>
      </tr>
      <tr>
        <td class="td-name">申请开始日期</td>
        <td><DateLabel :value="detailData.beginDate" /></td>
        <td class="td-name">申请结束日期</td>
        <td><DateLabel :value="detailData.endDate" /></td>
      </tr>
      <tr>
        <td class="td-name">到期自动结束</td>
        <td>
          <CommonLabel :dataList="boolList" valueKey="code" :value="detailData.isAutoEnd" />
        </td>
        <td class="td-name">是否可转入评审</td>
        <td>
          <CommonLabel :dataList="boolList" valueKey="code" :value="detailData.isReview" />
        </td>
      </tr>
      <tr>
        <td class="td-name">申请指南</td>
        <td>
          <template v-if="detailData.fileList">
            <p v-for="item in detailData.fileList" :key="item.id" class="my-[5px]">
              {{ item.fileName }}
              <el-link
                type="primary"
                @click="handleDownload(item.id, item.fileName)"
                class="ml-[5px]"
                >下载</el-link
              >
            </p>
          </template>
        </td>
        <td class="td-name">备注</td>
        <td>{{ detailData.note }}</td>
      </tr>
    </BaseTable>
  </div>
</template>

<script setup>
import BaseHead from "@/views/project/components/BaseHead.vue";
import BaseTable from "@/views/project/components/BaseTable.vue";
import DateLabel from "@/views/project/components/DateLabel.vue";
import CommonLabel from "@/views/project/components/CommonLabel.vue";
import CommonTreeLabel from "@/views/project/components/CommonTreeLabel.vue";
import { recordsDetail } from "@/api/project/xj/sbxm";
import useCommonFetch from "@/hooks/useCommonFetch";
import { handleDownload } from "@/utils/main";
const props = defineProps({
  operateId: String,
});
const boolList = useCommonFetch("是或否（存储值：1/0）");
const projectTypeList = useCommonFetch("项目分类（校级）");
const detailData = ref({});
//获取记录详情
const getDetail = async () => {
  try {
    const params = {
      id: props.operateId,
    };
    const res = await recordsDetail(params);
    detailData.value = res.data;
  } catch (error) {
    console.log(error);
  }
};
onMounted(() => {
  getDetail();
});
</script>

<style scoped lang="scss"></style>
